package com.topboya.linker.ui.adapter;

import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.support.v7.widget.RecyclerView;
import android.util.SparseBooleanArray;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.topboya.linker.R;
import com.topboya.linker.model.response.OrganizationResopnse;
import com.topboya.linker.model.response.VisitTypeResponse;
import com.topboya.linker.ui.activity.xSelectVistorActivity;
import com.topboya.linker.ui.base.adapter.BaseRecyclerAdapter;
import com.topboya.linker.utils.LogUtils;

import java.util.ArrayList;
import java.util.List;

public class xAuditedAdapter extends RecyclerView.Adapter<xAuditedAdapter.ListItemViewHolder> {

    private static final String TAG = "xAuditedAdapter:";
    private Context mConext;
    private List<OrganizationResopnse.DocDetailInfoList> mList;


    public xAuditedAdapter(Context mConext,List<OrganizationResopnse.DocDetailInfoList> list) {

        this.mConext = mConext;
        mList = list;
    }


    @Override
    public ListItemViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) {

        View itemView = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.create_device_item, viewGroup, false);
        return new ListItemViewHolder(itemView);
    }


    //绑定界面，设置监听
    @Override
    public void onBindViewHolder(final ListItemViewHolder holder, final int position) {
        //设置条目状态
        holder.tv_hasptial_name.setText(mList.get(position).getOrgName());

        //条目view的监听

        holder.itemView.setOnClickListener(v -> {

            if (null != itemClickListener){

                itemClickListener.onClick(holder.itemView ,position);
            }
        });

    }

    @Override
    public int getItemCount() {
        return mList == null ? 0 : mList.size();
    }

    public class ListItemViewHolder extends RecyclerView.ViewHolder{

        //ViewHolder
        TextView tv_hasptial_name;

        ListItemViewHolder(View view) {
            super(view);
            this.tv_hasptial_name = view.findViewById(R.id.tv_hasptial_name);

        }

    }

    private OnItemClickListener itemClickListener;

    public void setOnItemClickListener(OnItemClickListener itemClickListener){

        this.itemClickListener = itemClickListener;
    }

    public interface  OnItemClickListener{

        void onClick(View v,int position );
    }
}
